package com.xiaomaoguai.register;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class UserService {

	@Autowired
	private ApplicationContext applicationContext;

	public void registerUser(String username, String password) {
		System.out.println(username + "  注册成功！");
		publishRegisterEvent(new User(username, password));
	}

	private void publishRegisterEvent(User user) {
		applicationContext.publishEvent(new RegisterEvent(user));
	}

}
